//System includes
#include <windows.h>
#include <stdio.h>
//Ps specific includes 
#include "ps_support.h"




HINSTANCE ghAppInstance = NULL;
HWND ghMainWnd = NULL;

LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
	switch (message){
	/*case WM_COMMAND:
		handle menu selections etc.
		break;
	case WM_PAINT:
		draw our window - note: you must paint something here or not trap it!
		break;
	case WM_LBUTTONDOWN:
		
		break;
	case WM_RBUTTONDOWN:
		
		break;*/
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, str lpCmdLine, int nCmdShow){
	



	

	
	//Little block of code that checks cmd args, stores them in flagholder and checks which flags are active
	::u8 flagholder = SetArgFlags(lpCmdLine);//Yeah, wth only with :: scope, externals work for me xD	
	if(Flag(flagholder, debug)) MessageBox (NULL,"Debugging on" , "Arg Identifier", 0);
	//if(Flag(flagholder, godmode)) MessageBox (NULL,"Godmode on" , "Arg Identifier", 0);
	//End of Argument handling
	//To add more argument flags, first edit a placeholder in ps_globals.h, then also add it to ps_arguments.cpp
	
	

	ghAppInstance = hInstance;

	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.style= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc= (WNDPROC)MainWndProc;
	wcex.cbClsExtra= 0;
	wcex.cbWndExtra= 0;
	wcex.hInstance= ghAppInstance;
	wcex.hIcon= 0;
	wcex.hCursor= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName= 0;
	wcex.lpszClassName = "MyWindowClass";
	wcex.hIconSm= 0;

	RegisterClassEx(&wcex);

	ghMainWnd = CreateWindow("MyWindowClass", "The title of the Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, ghAppInstance, NULL);
	ShowWindow(ghMainWnd, nCmdShow);
	UpdateWindow(ghMainWnd);
	
	
	//Declare Debugwindow in scope
	DebugWindow upperleftie;
	
	//DEBUGWINDOW INITS here
	if(Flag(flagholder, debug)){
		MessageBox (NULL,"Debugging on" , "Arg Identifier", 0);
		
		upperleftie.Set("Debug Window", "MyWindowClass", 10,200,10,200,ghMainWnd,&wcex.cbSize);//follow random var cbSize
		upperleftie.Init();
		upperleftie.Update();
	}//End of Debug Window Init
	


	MSG msg;
	while(GetMessage(&msg, NULL, 0, 0)){
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return (int)msg.wParam;
}
